﻿/// <reference path="Common.js" />


Type.registerNamespace('Lib');

Lib.checkBox = function (element) {
    Lib.checkBox.initializeBase(this, [element]);

    this._onClientClick = null;
    this._Name = null;
    this._IsInputData = null;
    this._IsReset = null;

}

Lib.checkBox.prototype = {
    initialize: function () {
        Lib.checkBox.callBaseMethod(this, 'initialize');
        $addHandlers(this.get_element(),
                          {
                              'keydown': this._onKeyDown,
                              'click': this._onClick
                          },
                          this);

    },
    dispose: function () {
        //Xóa mọi event
        $clearHandlers(this.get_element());
        Lib.checkBox.callBaseMethod(this, 'dispose');
    },
    _onClick: function (e) {
        if (!Common.isNullOrEmty(this._onClientClick))
            window.setTimeout(this._onClientClick, 0);
    },
    _onKeyDown: function (e) {
        var control = this.get_element();
        var keycode = Common.getKeyCode(e);
        if (keycode == Sys.UI.Key.enter) {
            Common.onNextControl(control, e);
        }
    },
    get_onClientClick: function () {
        return this._onClientClick;
    },

    set_onClientClick: function (value) {
        if (this._onClientClick !== value)
            this._onClientClick = value;
    },
    get_Name: function () {
        return this._Name;
    }
    ,
    set_Name: function (value) {
        this._Name = value;
    },
    get_IsInputData: function () {
        return this._IsInputData;
    }
    ,
    set_IsInputData: function (value) {
        this._IsInputData = value;
    },
    get_IsReset: function () {
        return this._IsReset;
    }
    ,
    set_IsReset: function (value) {
        if (this._IsReset !== value)
            this._IsReset = value;
    },
    get_SaveTypeData: function()
    {
        return "String";
    }
}

Lib.checkBox.descriptor = {
    properties: [
        { name: 'onClientClick', type: String },
        { name: 'Name', type: String },
        { name: 'IsInputData', type: String },
        { name: 'IsReset', type: String }
    ]
}

Lib.checkBox.registerClass('Lib.checkBox', Sys.UI.Control);


if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();